﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using StreetsOfRageStyleGame.Enums;

namespace StreetsOfRageStyleGame
{
    class NonPlayerCharacter : CharacterSprite
    {
        public NonPlayerCharacter() { }

        public NonPlayerCharacter(GraphicsDeviceManager graphicsDeviceManager, Character character, CharacterAlignment characterAlignment, int characterHitPoints)
        {
            this.graphicsDeviceManager = graphicsDeviceManager;
            this.characterHitPoints = characterHitPoints;
            this.character = character;
            this.characterAlignment = characterAlignment;

            this.currentDirection = CharacterDirection.Left;
        }

        public void Update(GameTime theGameTime)
        {
            KeyboardState aCurrentKeyboardState = Keyboard.GetState();

            mPreviousKeyboardState = aCurrentKeyboardState;

            //Increase the timer by the number of milliseconds since update was last called
            timer += (float)theGameTime.ElapsedGameTime.TotalMilliseconds;

            //Check the timer is more than the chosen interval


            if (timer > interval)
            {
                currentFrame = GetNextFrame();
                //Reset the timer
                timer = 0f;
            }

          //  ticksSinceLastKeyPress++;

            //If we are on the last frame, reset back to the one before the first frame (because currentFrame++ is called next so the next frame will be 1!)

            Position += mDirection * mSpeed * (float)theGameTime.ElapsedGameTime.TotalSeconds;
            UpdateMovement(aCurrentKeyboardState);
        }

    }
}
